Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools oft miss.
The utf7 npm package provides utilities for encoding and decoding text using the UTF-7 encoding scheme. UTF-7 is a variable-length character encoding that was designed for representing Unicode text using a stream of ASCII characters. It is particularly useful for encoding text in environments that are not 8-bit clean, such as email systems.
Encoding to UTF-7
This feature allows you to encode a string into UTF-7 format. The provided code sample demonstrates how to encode the string 'Hello, World!' into its UTF-7 representation.
const utf7 = require('utf7');
const encoded = utf7.encode('Hello, World!');
console.log(encoded); // Outputs: 'Hello, World!'
Decoding from UTF-7
This feature allows you to decode a UTF-7 encoded string back into its original form. The provided code sample demonstrates how to decode the UTF-7 encoded string 'Hello, World!' back to 'Hello, World!'.
const utf7 = require('utf7');
const decoded = utf7.decode('Hello, World!');
console.log(decoded); // Outputs: 'Hello, World!'
The iconv-lite package provides pure JavaScript character encoding conversion. It supports a wide range of encodings, including UTF-8, UTF-16, and many legacy encodings. Unlike utf7, iconv-lite does not specifically focus on UTF-7 but offers broader encoding support.
The buffer package is a Node.js core module that provides a way of handling binary data directly in JavaScript. It supports various encoding schemes, including UTF-8 and Base64. While it does not specifically target UTF-7, it can be used for general encoding and decoding tasks.
Encodes and decodes JavaScript (Unicode/UCS-2) strings to UTF-7 ASCII strings. It supports two modes: UTF-7 as defined in RFC 2152 and Modified UTF-7 as defined by the IMAP standard in RFC 3501, section 5.1.3
RFC 2152
var utf7 = require('utf7');
var encoded = utf7.encode('Jyväskylä');
assert.equal('Jyv+AOQ-skyl+AOQ-', encoded);
var decoded = utf7.decode(encoded);
assert.equal('Jyväskylä', decoded);
By default, .encode()
only encodes the default characeters defined in RFC 2152. To also encode optional characters, use .encodeAll()
or specify the characters you want to encode as the second argument to .encode()
.
IMAP (RFC 3501)
var utf7 = require('utf7').imap;
var encoded = utf7.encode('"你好" heißt "Hallo"');
assert.equal('"&T2BZfQ-" hei&AN8-t "Hallo"', encoded);
var decoded = utf7.decode(encoded);
assert.equal('"你好" heißt "Hallo"', decoded);
FAQs
Converts text to and from UTF-7 (RFC 2152 and IMAP)
We found that utf7 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools oft miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.